package org.swust.sysmonitorapp.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.swust.sysmonitorapp.entity.AlertThreshold;
import org.swust.sysmonitorapp.entity.R;
import org.swust.sysmonitorapp.service.IAlertThresholdService;

@RestController
@RequestMapping("/alert-threshold")
public class AlertThresholdController {

    @Autowired
    private IAlertThresholdService thresholdService;

    @GetMapping("/{deviceId}")
    public R<AlertThreshold> getThreshold(@PathVariable String deviceId) {
        return R.ok(thresholdService.getById(deviceId));
    }

    @PutMapping
    public R<Boolean> updateThreshold(@RequestBody AlertThreshold threshold) {
        return R.ok(thresholdService.updateThreshold(threshold));
    }
}